import Taro, { Component } from '@tarojs/taro'
import { View, Image } from '@tarojs/components'
import './index.scss'
import emptyData from '@/assets/icon/empty-data.png'
import emptyOrder from '../../assets/icon/empty-order.png'
import emptyCollect from '../../assets/icon/empty-collect.png'
import emptyNetwork from '../../assets/icon/empty-network.png'

interface IProps {
  type?: string
}

export default class EmptyData extends Component<IProps, {}> {
  constructor () {
    super(...arguments)
    this.state = {
      images: {
        order: { title: '暂无订单', src: emptyOrder },
        record: { title: '暂无记录', src: emptyData },
        collect: { title: '暂无收藏', src: emptyCollect },
        network: { title: '暂无网络', src: emptyNetwork },
      }
    }
  }

  render() {
    const { images }:any = this.state
    const { type='record' } = this.props

    return (<View className='empty-data'>
      <View className='empty-body'>
        <Image className='empty-img' src={images[type]['src']}/>
        <View className='empty-text'>{images[type]['title']}</View>
      </View>
    </View>)
  }
}
